package cf.huzpsb.lias;

import net.md_5.bungee.api.event.LoginEvent;
import net.md_5.bungee.api.event.ServerSwitchEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;

public class PlayerListener implements Listener {
    @EventHandler
    public void onLogin(LoginEvent event) {
        if (Main.getstat(event.getConnection().getName()) || Main.getstat(event.getConnection().getAddress().getAddress().getHostAddress().replace(".", "D"))) {
            event.setCancelReason(Main.reason);
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void onTeleport(ServerSwitchEvent event) {
        if (!event.getPlayer().getServer().getInfo().getName().equals(Main.hub)) {
            Main.merge(event.getPlayer().getName(), event.getPlayer().getAddress().getAddress().getHostAddress().replace(".", "D"));
        }
    }
}
